#include <iostream>
using namespace std;
int main()
{
    int n = 0;
    cin >> n;
    int i = 0;
    int sum = 1;
    for (i = 1; i <= n; i++)
    {
        int a = i * i;
        int old = i;
        while (old)
        {
            if ((old % 10) != (a % 10))
                break;
            old /= 10;
            a /= 10;
        }
        if (old == 0)
            sum += 1;
    }
    cout << sum << endl;
    return 0;
}